const Mock = require('mockjs')

const loginLog = Mock.mock({
  'data|10': [{
    id: '@id',
    username: '@cname',
    ip: '@ip',
    location: '@city',
    'os|1': ['windows7', 'MacOS', 'Android'],
    'browser|1': ['chrome', 'MicrosoftEdge', 'QQ浏览器'],
    'status|1': ['1', '0'],
    'message|1': ['登录成功', '登录失败'],
    createTime: '@datetime'
  }]
})

const operationLog = Mock.mock({
  'data|10': [{
    id: '@id',
    'title|1': ['菜单管理', '字典管理'],
    'operationType|1': ['1', '2', '3'],
    'requestMethod|1': ['GET', 'POST', 'PUT', 'DELETE'],
    operator: '@cname',
    ip: '@ip',
    location: '@city',
    'status|1': ['1', '0'],
    cost: '@integer(10, 500)',
    url: '@url',
    method: 'com.sunxueqi.controller.UserController.addUser()',
    params: '张三 18',
    returnMessage: '{"message":"新旧密码不能相同","code":200}',
    createTime: '@datetime'
  }]
})

const visitLog = Mock.mock({
  'data|10': [{
    id: '@id',
    'title|1': ['菜单管理', '字典管理'],
    ip: '@ip',
    location: '@city',
    'os|1': ['windows7', 'MacOS', 'Android'],
    'browser|1': ['chrome', 'MicrosoftEdge', 'QQ浏览器'],
    'status|1': ['1', '0'],
    createTime: '@datetime'
  }]
})

module.exports = [
  // 获取登录日志
  {
    url: '/log/loginLog/list',
    type: 'get',
    response: _ => {
      return {
        code: 200,
        message: '操作成功',
        data: loginLog.data,
        total: 300
      }
    }
  },
  // 删除登录日志
  {
    url: '/log/loginLog',
    type: 'delete',
    response: _ => {
      return {
        code: 200,
        messge: '操作成功'
      }
    }
  },
  // 获取操作日志
  {
    url: '/log/operationLog/list',
    type: 'get',
    response: _ => {
      return {
        code: 200,
        message: '操作成功',
        data: operationLog.data,
        total: 250
      }
    }
  },
  // 删除操作日志
  {
    url: '/log/operationLog',
    type: 'delete',
    response: _ => {
      return {
        code: 200,
        messge: '操作成功'
      }
    }
  },
  // 获取访问日志
  {
    url: '/log/visitLog/list',
    type: 'get',
    response: _ => {
      return {
        code: 200,
        message: '操作成功',
        data: visitLog.data,
        total: 250
      }
    }
  },
  // 删除访问日志
  {
    url: '/log/visitLog',
    type: 'delete',
    response: _ => {
      return {
        code: 200,
        messge: '操作成功'
      }
    }
  }
]
